package com.itheima.service.impl;

import com.itheima.domain.Comment;
import com.itheima.domain.CommentExample;
import com.itheima.mapper.CommentMapper;
import com.itheima.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> findCommentByMoviesId(Integer moviesId) {
        CommentExample commentExample = new CommentExample();
        commentExample.createCriteria().andMoviesIdEqualTo(moviesId);
        List<Comment> commentList = commentMapper.selectByExample(commentExample);
        return commentList;
    }

    @Override
    public void saveComment(Comment comment) {
        commentMapper.insertSelective(comment);
    }
}
